/*      */ package com.qmsk.business.store.salebill.controller;
/*      */ 
/*      */ import com.qmsk.business.bussBill.bussBill.dao.BussBillDao;
/*      */ import com.qmsk.business.bussBill.pbPaid.PbPaid;
/*      */ import com.qmsk.business.member.bussbillpaycheck.dao.BussBillPayCheckDao;
/*      */ import com.qmsk.business.member.bussbillpaypos.dao.BussBillPayPosDAO;
/*      */ import com.qmsk.business.member.member.dao.MemberDAO;
/*      */ import com.qmsk.business.member.memberAct.MemberActConst;
/*      */ import com.qmsk.business.member.memberCashCoupConsumeRecord.dao.MemberCashCouponConsumeRecordDAO;
/*      */ import com.qmsk.business.member.memberCashCoupDetail.dao.MemberCashCouponDetailDAO;
/*      */ import com.qmsk.business.member.memberIntegralConsumeRecord.dao.MemberIntegralConsumeRecordDAO;
/*      */ import com.qmsk.business.member.memberIntegralDetail.dao.MemberIntegralDetailDAO;
/*      */ import com.qmsk.business.member.memberLog.dao.MemberLogDAO;
/*      */ import com.qmsk.business.member.shopMember.dao.ShopMemberDAO;
/*      */ import com.qmsk.business.shopList.ShopMap;
/*      */ import com.qmsk.business.store.outstockbill.service.OutStockBillService;
/*      */ import com.qmsk.business.store.salebill.dao.SaleBillDao;
/*      */ import com.qmsk.business.store.salebill.params.SaleBillModel;
/*      */ import com.qmsk.business.store.salebillpay.dao.SaleBillPayDAO;
/*      */ import com.qmsk.business.store.salebillpayvcard.dao.SaleBillPayVCardDAO;
/*      */ import com.qmsk.business.store.saledetail.dao.SaleDetailDao;
/*      */ import com.qmsk.business.store.vicecard.dao.ViceCardDao;
/*      */ import com.qmsk.session.UserSessionInfo;
/*      */ import com.qmsk.session.bean.CSessionUser;
/*      */ import com.utils.basic.MapUtils;
/*      */ import com.utils.basic.ObjectComm;
/*      */ import com.utils.crypt.AESUtils;
/*      */ import com.utils.gson.in.GsonHeadManyRows;
/*      */ import com.utils.gson.in.GsonHeadOneRow;
/*      */ import com.utils.gson.in.ParserDataSetJson;
/*      */ import com.utils.gson.out.GsonEbRst;
/*      */ import com.utils.http.HttpGsonPtResponseUtils;
/*      */ import com.utils.jdbc.connection.DbConnection;
/*      */ import com.utils.web.RequestUtils;
/*      */ import com.utils.web.ResponseUtils;
/*      */ import java.sql.SQLException;
/*      */ import java.util.Date;
/*      */ import java.util.HashMap;
/*      */ import java.util.List;
/*      */ import java.util.Map;
/*      */ import javax.servlet.http.HttpServletRequest;
/*      */ import javax.servlet.http.HttpServletResponse;
/*      */ import org.apache.log4j.Logger;
/*      */ import org.springframework.beans.factory.annotation.Autowired;
/*      */ import org.springframework.stereotype.Controller;
/*      */ import org.springframework.transaction.annotation.Transactional;
/*      */ import org.springframework.web.bind.annotation.PathVariable;
/*      */ import org.springframework.web.bind.annotation.RequestMapping;
/*      */ 
/*      */ @Controller
/*      */ @RequestMapping({"saleBill"})
/*      */ public class SaleBillController
/*      */ {
/*   65 */   private static final Logger logger = Logger.getLogger(SaleBillController.class);
/*      */ 
/*      */   @Autowired
/*      */   private SaleBillDao dao;
/*      */ 
/*      */   @Autowired
/*      */   private MemberLogDAO memberLogDAO;
/*      */ 
/*      */   @Autowired
/*      */   private MemberDAO memberDAO;
/*      */ 
/*      */   @Autowired
/*      */   private ShopMemberDAO shopMemberDAO;
/*      */ 
/*      */   @Autowired
/*      */   private BussBillPayCheckDao bussbillpaycheckDao;
/*      */ 
/*      */   @Autowired
/*      */   private BussBillPayPosDAO bussbillPayPosDao;
/*      */ 
/*      */   @Autowired
/*      */   private SaleBillPayVCardDAO saleBillPayVCardDao;
/*      */ 
/*      */   @Autowired
/*      */   private MemberIntegralDetailDAO integralDetailDAO;
/*      */ 
/*      */   @Autowired
/*      */   private MemberIntegralConsumeRecordDAO integralConsumeRecordDAO;
/*      */ 
/*      */   @Autowired
/*      */   private MemberCashCouponDetailDAO memberCashCouponDetailDAO;
/*      */ 
/*      */   @Autowired
/*      */   private MemberCashCouponConsumeRecordDAO memberCashCouponConsumeRecordDAO;
/*      */ 
/*      */   @Autowired
/*      */   private SaleDetailDao saleDetailDao;
/*      */ 
/*      */   @Autowired
/*      */   private SaleBillPayDAO saleBillPayDAO;
/*      */ 
/*      */   @Autowired
/*      */   private BussBillDao bussbillDao;
/*      */ 
/*      */   @Autowired
/*      */   private ViceCardDao viceCardDao;
/*      */ 
/*      */   @Autowired
/*      */   private OutStockBillService outStockBillService;
/*      */ 
/*      */   @RequestMapping(value={"find/shopId/{shopId}/sale/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*      */   public void getListShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*      */   {
/*  142 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*      */     try {
/*  144 */       Map params = new HashMap();
/*  145 */       MapUtils.addToMap(params, "shopId", shopId);
/*  146 */       MapUtils.addToMap(params, "dtPaidStart", 
/*  147 */         RequestUtils.getString(request, "dtPaidStart"));
/*  148 */       MapUtils.addToMap(params, "dtPaidEnd", 
/*  149 */         RequestUtils.getString(request, "dtPaidEnd"));
/*  150 */       MapUtils.addToMap(params, "status", 
/*  151 */         RequestUtils.getInt(request, "status"));
/*  152 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopIdAndRtime(params, nPageIdx, 
/*  153 */         nPageSize);
/*  154 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*      */     } catch (SQLException e) {
/*  156 */       logger.error(e);
/*  157 */       ResponseUtils.setErrorMsgResponse(
/*  158 */         RequestUtils.getFindDataErrorMessage(request), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @RequestMapping(value={"find/shopId/{shopId}/sale/sum"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*      */   public void getListShopIdSum(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId)
/*      */   {
/*      */     try
/*      */     {
/*  175 */       Map params = new HashMap();
/*  176 */       MapUtils.addToMap(params, "shopId", shopId);
/*  177 */       MapUtils.addToMap(params, "dtPaidStart", 
/*  178 */         RequestUtils.getString(request, "dtPaidStart"));
/*  179 */       MapUtils.addToMap(params, "dtPaidEnd", 
/*  180 */         RequestUtils.getString(request, "dtPaidEnd"));
/*  181 */       MapUtils.addToMap(params, "status", 
/*  182 */         RequestUtils.getInt(request, "status"));
/*  183 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopIdSum(params);
/*  184 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*      */     } catch (SQLException e) {
/*  186 */       logger.error(e);
/*  187 */       ResponseUtils.setErrorMsgResponse(
/*  188 */         RequestUtils.getFindDataErrorMessage(request), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @RequestMapping(value={"find/shopId/{shopId}/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*      */   public void getListOptShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*      */   {
/*  197 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*      */     try {
/*  199 */       Map params = new HashMap();
/*  200 */       MapUtils.addToMap(params, "shopId", shopId);
/*  201 */       MapUtils.addPercentToMap(params, "producer", 
/*  202 */         RequestUtils.getString(request, "producer", null));
/*  203 */       MapUtils.addPercentToMap(params, "title", 
/*  204 */         RequestUtils.getString(request, "title", null));
/*  205 */       MapUtils.addPercentToMap(params, "content", 
/*  206 */         RequestUtils.getString(request, "content", null));
/*  207 */       MapUtils.addToMap(params, "dtReqStart", 
/*  208 */         RequestUtils.getDate(request, "dtReqStart", null));
/*  209 */       MapUtils.addToMap(params, "dtReqEnd", 
/*  210 */         RequestUtils.getDate(request, "dtReqEnd", null));
/*  211 */       MapUtils.addToMap(params, "dtSendStart", 
/*  212 */         RequestUtils.getDate(request, "dtSendStart", null));
/*  213 */       MapUtils.addToMap(params, "dtSendEnd", 
/*  214 */         RequestUtils.getDate(request, "dtSendEnd", null));
/*  215 */       MapUtils.addToMap(params, "status", 
/*  216 */         RequestUtils.getInt(request, "status", null));
/*  217 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(params, nPageIdx, 
/*  218 */         nPageSize);
/*  219 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*      */     } catch (Exception e) {
/*  221 */       logger.error(e);
/*  222 */       ResponseUtils.setErrorMsgResponse(
/*  223 */         RequestUtils.getFindDataErrorMessage(request), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @RequestMapping(value={"find/shopId/{shopId}/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*      */   public void getListId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") Long id)
/*      */   {
/*      */     try {
/*  231 */       GsonEbRst gsonEbRst = this.dao.getGsonOfId(id);
/*  232 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*      */     } catch (SQLException e) {
/*  234 */       logger.error(e);
/*  235 */       ResponseUtils.setErrorMsgResponse(
/*  236 */         RequestUtils.getFindDataErrorMessage(request), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @RequestMapping(value={"find/shopId/{shopId}/detl/{saleId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*      */   public void getListDetlId(HttpServletRequest request, HttpServletResponse response, @PathVariable("saleId") Long saleId)
/*      */   {
/*      */     try {
/*  244 */       GsonEbRst gsonEbRst = this.saleDetailDao.getGsonOfSaleId(saleId);
/*  245 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*      */     } catch (SQLException e) {
/*  247 */       logger.error(e);
/*  248 */       ResponseUtils.setErrorMsgResponse(
/*  249 */         RequestUtils.getFindDataErrorMessage(request), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @RequestMapping(value={"find/shopId/{shopId}/stId/paid/date/sum"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*      */   public void getSumShopIdStIdDate(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId)
/*      */   {
/*      */   }
/*      */ 
/*      */   @RequestMapping(value={"find/shopId/{shopId}/paid/date/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*      */   public void getListShopIdStIdDate(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*      */   {
/*  290 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*      */     try {
/*  292 */       Map params = new HashMap();
/*  293 */       MapUtils.addToMap(params, "shopId", shopId);
/*  294 */       MapUtils.addToMap(params, "billNo", 
/*  295 */         RequestUtils.getString(request, "billNo"));
/*  296 */       MapUtils.addToMap(params, "dtPaidStart", 
/*  297 */         RequestUtils.getString(request, "dtPaidStart"));
/*  298 */       MapUtils.addToMap(params, "dtPaidEnd", 
/*  299 */         RequestUtils.getString(request, "dtPaidEnd"));
/*  300 */       MapUtils.addToMap(params, "dtMakeStart", 
/*  301 */         RequestUtils.getString(request, "dtMakeStart"));
/*  302 */       MapUtils.addToMap(params, "dtMakeEnd", 
/*  303 */         RequestUtils.getString(request, "dtMakeEnd"));
/*      */ 
/*  306 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(params, nPageIdx, 
/*  307 */         nPageSize);
/*  308 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*      */     } catch (SQLException e) {
/*  310 */       logger.error(e);
/*  311 */       ResponseUtils.setErrorMsgResponse(
/*  312 */         RequestUtils.getFindDataErrorMessage(request), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @Transactional
/*      */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*      */   public void insertList(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId)
/*      */   {
/*      */     try
/*      */     {
/*  330 */       int nResult = 0;
/*  331 */       String billNo = null;
/*  332 */       Long id = null;
/*  333 */       ParserDataSetJson p = new ParserDataSetJson(
/*  334 */         request.getParameter("data"));
/*  335 */       if (p != null) {
/*  336 */         if (p.isExistsInsertRows()) {
/*  337 */           for (int i = 0; i < p.getListInsertRows().size(); ++i) {
/*  338 */             GsonHeadOneRow r = (GsonHeadOneRow)p.getListInsertRows().get(i);
/*  339 */             billNo = this.dao.getMaxBillNo(shopId);
/*  340 */             r.autoAddHeadData("billNo", billNo);
/*  341 */             r.autoAddHeadData("sdeTypeId", Integer.valueOf(26));
/*      */           }
/*      */         }
/*  344 */         nResult = this.dao.applyUpdates(p, "id");
/*  345 */         if ((p.isExistsInsertRows()) && (nResult > 0)) {
/*  346 */           GsonHeadOneRow r = (GsonHeadOneRow)p.getListInsertRows().get(0);
/*  347 */           id = ObjectComm.objectToLong(r.getValueOfName("id"));
/*      */         }
/*      */       }
/*      */       ParserDataSetJson pCheck;
/*      */       int i;
/*      */       GsonHeadOneRow r;
/*  350 */       if ((nResult > 0) || (p == null) || (p.isExistsRows())) {
/*  351 */         pCheck = ParserDataSetJson.fromString(request
/*  352 */           .getParameter("detl"));
/*  353 */         if (pCheck != null) {
/*  354 */           if (pCheck.isExistsInsertRows()) {
/*  355 */             for (i = 0; i < pCheck.getListInsertRows().size(); ++i) {
/*  356 */               r = 
/*  357 */                 (GsonHeadOneRow)pCheck.getListInsertRows()
/*  357 */                 .get(i);
/*  358 */               if (id != null) {
/*  359 */                 r.autoAddHeadData("ID", id);
/*      */               }
/*      */             }
/*      */           }
/*  363 */           nResult += this.saleDetailDao.applyUpdates(pCheck);
/*      */         }
/*      */       }
/*  366 */       if ((nResult > 0) || (p == null) || (p.isExistsRows())) {
/*  367 */         pCheck = 
/*  368 */           ParserDataSetJson.fromString(RequestUtils.getString(request, "pay"));
/*  369 */         if (pCheck != null) {
/*  370 */           if (pCheck.isExistsInsertRows()) {
/*  371 */             for (i = 0; i < pCheck.getListInsertRows().size(); ++i) {
/*  372 */               r = 
/*  373 */                 (GsonHeadOneRow)pCheck.getListInsertRows()
/*  373 */                 .get(i);
/*  374 */               if (id != null) {
/*  375 */                 r.autoAddHeadData("id", id);
/*      */               }
/*      */             }
/*      */           }
/*  379 */           nResult = this.saleBillPayDAO.applyUpdates(pCheck);
/*      */         }
/*      */       }
/*  382 */       if ((nResult > 0) || (p == null) || (p.isExistsRows())) {
/*  383 */         pCheck = 
/*  384 */           ParserDataSetJson.fromString(RequestUtils.getString(request, "chkPay"));
/*  385 */         if (pCheck != null) {
/*  386 */           if (pCheck.isExistsInsertRows()) {
/*  387 */             for (i = 0; i < pCheck.getListInsertRows().size(); ++i) {
/*  388 */               r = 
/*  389 */                 (GsonHeadOneRow)pCheck.getListInsertRows()
/*  389 */                 .get(i);
/*  390 */               if (id != null) {
/*  391 */                 r.autoAddHeadData("id", id);
/*      */               }
/*      */             }
/*      */           }
/*  395 */           nResult += this.bussbillpaycheckDao.applyUpdates(pCheck);
/*      */         }
/*      */       }
/*  398 */       if ((nResult > 0) || (p == null) || (p.isExistsRows())) {
/*  399 */         pCheck = 
/*  400 */           ParserDataSetJson.fromString(RequestUtils.getString(request, "posPay"));
/*  401 */         if (pCheck != null) {
/*  402 */           if (pCheck.isExistsInsertRows()) {
/*  403 */             for (i = 0; i < pCheck.getListInsertRows().size(); ++i) {
/*  404 */               r = 
/*  405 */                 (GsonHeadOneRow)pCheck.getListInsertRows()
/*  405 */                 .get(i);
/*  406 */               if (id != null) {
/*  407 */                 r.autoAddHeadData("id", id);
/*      */               }
/*      */             }
/*      */           }
/*  411 */           nResult += this.bussbillPayPosDao.applyUpdates(pCheck);
/*      */         }
/*      */       }
/*      */ 
/*  415 */       if ((nResult > 0) || (p == null) || (p.isExistsRows())) {
/*  416 */         pCheck = 
/*  417 */           ParserDataSetJson.fromString(RequestUtils.getString(request, "vicePay"));
/*  418 */         if (pCheck != null) {
/*  419 */           if (pCheck.isExistsInsertRows()) {
/*  420 */             for (i = 0; i < pCheck.getListInsertRows().size(); ++i) {
/*  421 */               r = 
/*  422 */                 (GsonHeadOneRow)pCheck.getListInsertRows()
/*  422 */                 .get(i);
/*  423 */               if (id != null) {
/*  424 */                 r.autoAddHeadData("saleId", id);
/*      */               }
/*      */             }
/*      */           }
/*  428 */           nResult += this.saleBillPayVCardDao.applyUpdates(pCheck);
/*      */         }
/*      */       }
/*      */ 
/*  432 */       if (nResult > 0) {
/*  433 */         DbConnection.commit();
/*  434 */         if (id != null) {
/*  435 */           String[] heads = { "id", "billNo" };
/*  436 */           Object[] datas = { id, billNo };
/*  437 */           ResponseUtils.toGsonEbRst(heads, datas, response);
/*  438 */           return; }
/*  439 */         ResponseUtils.setSqlResultResponse(nResult, 
/*  440 */           RequestUtils.getSqlInsertDataErrorMessage(request), 
/*  441 */           response);
/*      */ 
/*  443 */         return; }
/*  444 */       DbConnection.rollback();
/*  445 */       ResponseUtils.setSqlResultResponse(nResult, 
/*  446 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/*  447 */         response);
/*      */     }
/*      */     catch (Exception e) {
/*  450 */       DbConnection.rollback();
/*  451 */       logger.error(e);
/*  452 */       ResponseUtils.setErrorMsgResponse(
/*  453 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/*  454 */         e.getMessage(), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @Transactional
/*      */   @RequestMapping(value={"paid/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*      */   public void paidCustId(HttpServletRequest request, @PathVariable("shopId") Long shopId, HttpServletResponse response)
/*      */   {
/*  471 */     Long id = RequestUtils.getLong(request, "id");
/*  472 */     Long userId = UserSessionInfo.getIntUserIdOfRequest(request);
/*  473 */     String userName = UserSessionInfo.getUserNameOfRequest(request);
/*  474 */     String billNo = null;
/*  475 */     String outNo = null;
/*  476 */     int nResult = 0;
/*      */     try
/*      */     {
/*  479 */       nResult = this.dao.updateBillPaidOfIds(id, userName);
/*      */ 
/*  481 */       if ((nResult > 0) && (id != null)) {
/*  482 */         GsonHeadOneRow r = this.dao.getOneRowOfId(id);
/*  483 */         billNo = (String)r.getValueOfName("billNo");
/*  484 */         Double viceAmt = ObjectComm.objectToDouble(
/*  485 */           r.getValueOfName("viceAmt"), Double.valueOf(0.0D));
/*  486 */         if (viceAmt.doubleValue() > 0.0D) {
/*  487 */           nResult = paidViceCard(id, shopId, request, response);
/*      */         }
/*  489 */         Double payDepstAmt = ObjectComm.objectToDouble(
/*  490 */           r.getValueOfName("depstAmt"), Integer.valueOf(0));
/*  491 */         Double payCredit = ObjectComm.objectToDouble(
/*  492 */           r.getValueOfName("regAmt"), Integer.valueOf(0));
/*  493 */         Double payCashCoupAmtMny = ObjectComm.objectToDouble(
/*  494 */           r.getValueOfName("cashCoupAmt"), Integer.valueOf(0));
/*  495 */         if (payDepstAmt.doubleValue() > 0.0D) {
/*  496 */           ResponseUtils.setErrorMsgResponse("闈炰細鍛樹笉鑳戒娇鐢ㄩ瀛樻敮浠�", response);
/*  497 */           return;
/*      */         }
/*  499 */         if (payCredit.doubleValue() > 0.0D) {
/*  500 */           ResponseUtils.setErrorMsgResponse("闈炰細鍛樹笉鑳戒娇鐢ㄦ寕璐︽敮浠�", response);
/*  501 */           return;
/*      */         }
/*  503 */         if (payCashCoupAmtMny.doubleValue() > 0.0D) {
/*  504 */           ResponseUtils.setErrorMsgResponse("闈炰細鍛樹笉鑳戒娇鐢ㄤ唬閲戝嵎鏀粯", response);
/*  505 */           return;
/*      */         }
/*      */       }
/*  508 */       if (nResult > 0) {
/*  509 */         outNo = this.outStockBillService.getOutNo(shopId);
/*  510 */         String[] head = { "shopId", "outTpId", "outNo", 
/*  511 */           "linkNo", "maker", "makeDate", "status", "outDate" };
/*  512 */         Object[] data = { shopId, Integer.valueOf(1), outNo, billNo, 
/*  513 */           userName, new Date(), Integer.valueOf(1), new Date() };
/*  514 */         GsonHeadManyRows m = this.saleDetailDao
/*  515 */           .getManyRowsGoodsDetailOfSaleId(id);
/*  516 */         nResult = this.outStockBillService.insertOutBill(
/*  517 */           new GsonHeadOneRow(head, data), m).intValue();
/*      */ 
/*  518 */         if (nResult > 0) {
/*  519 */           Long outId = this.outStockBillService.getLastId();
/*  520 */           nResult = this.outStockBillService.check(outId, response).intValue();
/*      */         }
/*      */       }
/*  523 */       if (nResult > 0)
/*      */       {
/*  525 */         GsonHeadOneRow g = this.dao.getSaleIdOfSaleName(id);
/*  526 */         Map params = new HashMap();
/*  527 */         MapUtils.addToMap(params, "stId", Integer.valueOf(26));
/*  528 */         MapUtils.addToMap(params, "userId", userId);
/*  529 */         MapUtils.addToMap(params, "userName", userName);
/*  530 */         params.put("id", id);
/*  531 */         if ((g != null) && (g.isExistsData())) {
/*  532 */           params.put("saleId", g.getValueOfName("sUserId"));
/*  533 */           params.put("saleName", g.getValueOfName("sUserName"));
/*      */         }
/*  535 */         this.bussbillDao.inserBussbillOfSalebill(params);
/*      */       }
/*  537 */       if (nResult > 0)
/*  538 */         DbConnection.commit();
/*      */       else {
/*  540 */         DbConnection.rollback();
/*      */       }
/*  542 */       ResponseUtils.setSqlResultResponse(nResult, 
/*  543 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/*  544 */         response);
/*      */     } catch (Exception e) {
/*  546 */       DbConnection.rollback();
/*  547 */       logger.error(e);
/*  548 */       ResponseUtils.setErrorMsgResponse(
/*  549 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/*  550 */         e.getMessage(), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   private int paidViceCard(Long SaleId, Long shopId, HttpServletRequest request, HttpServletResponse response)
/*      */   {
/*  556 */     int nResult = 0;
/*      */     try {
/*  558 */       GsonHeadManyRows m = this.saleBillPayVCardDao.getManyRowsOfId(SaleId);
/*  559 */       for (int i = 0; i < m.getDataLength(); ++i) {
/*  560 */         Long vCardId = ObjectComm.objectToLong(m.getValueOfName(
/*  561 */           "vCardId", i));
/*  562 */         Double tmpAmt = ObjectComm.objectToDouble(
/*  563 */           m.getValueOfName("tmpAmt", i), Double.valueOf(0.0D));
/*  564 */         Double amt = ObjectComm.objectToDouble(
/*  565 */           m.getValueOfName("amt", i), Double.valueOf(0.0D));
/*  566 */         Integer status = ObjectComm.objectToInteger(m.getValueOfName(
/*  567 */           "status", i));
/*  568 */         if (amt.doubleValue() >= tmpAmt.doubleValue()) {
/*  569 */           amt = Double.valueOf(amt.doubleValue() - tmpAmt.doubleValue());
/*      */         } else {
/*  571 */           ResponseUtils.setErrorMsgResponse("鍗″彿涓�" + vCardId + 
/*  572 */             "鎻愯揣鍗′綑棰濅笉瓒�", response);
/*  573 */           return -1;
/*      */         }
/*  575 */         GsonHeadOneRow g = null;
/*  576 */         if (status.intValue() == 3) {
/*  577 */           Map params = new HashMap();
/*  578 */           MapUtils.addToMap(params, "amt", amt);
/*  579 */           MapUtils.addToMap(params, "id", vCardId);
/*  580 */           nResult += this.viceCardDao.updatePayNoOneOfId(params);
/*  581 */           String[] heads = { "amt", "id" };
/*  582 */           Object[] datas = { amt, vCardId };
/*  583 */           g = new GsonHeadOneRow(heads, datas);
/*  584 */         } else if (status.intValue() == 2) {
/*  585 */           String mp = (String)m.getValueOfName("mp", i);
/*  586 */           String payPsd = (String)m.getValueOfName("payPsd", i);
/*  587 */           Map params = new HashMap();
/*  588 */           MapUtils.addToMap(params, "status", 
/*  589 */             Integer.valueOf(3));
/*  590 */           MapUtils.addToMap(params, "mp", mp);
/*  591 */           MapUtils.addToMap(params, "payPsd", AESUtils.getInst()
/*  592 */             .encrypt(payPsd));
/*  593 */           MapUtils.addToMap(params, "amt", amt);
/*  594 */           MapUtils.addToMap(params, "id", vCardId);
/*  595 */           nResult += this.viceCardDao.updatePayOneOfId(params);
/*  596 */           String[] heads = { "status", "mp", "payPsd", 
/*  597 */             "amt", "id" };
/*  598 */           Object[] datas = { Integer.valueOf(3), 
/*  599 */             mp, payPsd, amt, vCardId };
/*  600 */           g = new GsonHeadOneRow(heads, datas);
/*      */         }
/*      */ 
/*  603 */         nResult = nResult + 
/*  603 */           toPtPay(g.objectToJsonStr(), 
/*  603 */           ShopMap.getOutIdOfShopId(shopId), response).intValue();
/*      */       }
/*      */     } catch (Exception e) {
/*  606 */       logger.error(e);
/*  607 */       ResponseUtils.setErrorMsgResponse(
/*  608 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/*  609 */         e.getMessage(), response);
/*      */     }
/*  611 */     return nResult;
/*      */   }
/*      */ 
/*      */   private Integer toPtPay(String sGsonInData, Long shopId, HttpServletResponse response) throws Exception
/*      */   {
/*  616 */     String sData = "data=" + sGsonInData + "&shopId=" + 
/*  617 */       shopId;
/*  618 */     String url = "ptViceCard/edit/pay";
/*  619 */     GsonEbRst rst = 
/*  620 */       HttpGsonPtResponseUtils.getPtEbRst(url, sData, response);
/*  621 */     if ((rst != null) && (rst.getState() == 0)) {
/*  622 */       return Integer.valueOf(1);
/*      */     }
/*  624 */     return null;
/*      */   }
/*      */ 
/*      */   @Transactional
/*      */   @RequestMapping(value={"paid/shopId/{shopId}/member"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*      */   public void paidMember(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*      */   {
/*  641 */     Long id = RequestUtils.getLong(request, "id");
/*  642 */     int nResult = 0;
/*  643 */     Long userId = UserSessionInfo.getIntUserIdOfRequest(request);
/*  644 */     String userName = UserSessionInfo.getUserNameOfRequest(request);
/*  645 */     String outNo = null;
/*  646 */     SaleBillModel saleBillModel = new SaleBillModel();
/*      */     try {
/*  648 */       nResult = this.dao.updateBillPaidOfIds(id, userName);
/*  649 */       if (nResult > 0) {
/*  650 */         GsonHeadOneRow g = this.dao.getSaleIdOfSaleName(id);
/*  651 */         Map params = new HashMap();
/*  652 */         MapUtils.addToMap(params, "stId", Integer.valueOf(26));
/*  653 */         MapUtils.addToMap(params, "userId", userId);
/*  654 */         MapUtils.addToMap(params, "userName", userName);
/*  655 */         params.put("id", id);
/*  656 */         if ((g != null) && (g.isExistsData())) {
/*  657 */           params.put("saleId", g.getValueOfName("sUserId"));
/*  658 */           params.put("saleName", g.getValueOfName("sUserName"));
/*      */         }
/*  660 */         this.bussbillDao.inserBussbillOfSalebill(params);
/*      */       }
/*  662 */       if (nResult > 0) {
/*  663 */         Long bussId = this.bussbillDao.getLastId();
/*  664 */         nResult = paidDetailOfbsbill(id, bussId, userId, userName, 
/*  665 */           saleBillModel, request, response);
/*      */       }
/*      */ 
/*  668 */       if (nResult > 0) {
/*  669 */         outNo = this.outStockBillService.getOutNo(shopId);
/*  670 */         String[] head = { "shopId", "outTpId", "outNo", 
/*  671 */           "linkNo", "maker", "makeDate", "status", "outDate" };
/*  672 */         Object[] data = { shopId, Integer.valueOf(1), outNo, saleBillModel.getBillNo(), 
/*  673 */           userName, new Date(), Integer.valueOf(1), new Date() };
/*  674 */         GsonHeadManyRows m = this.saleDetailDao
/*  675 */           .getManyRowsGoodsDetailOfSaleId(id);
/*  676 */         nResult = this.outStockBillService.insertOutBill(
/*  677 */           new GsonHeadOneRow(head, data), m).intValue();
/*      */ 
/*  678 */         if (nResult > 0) {
/*  679 */           Long outId = this.outStockBillService.getLastId();
/*  680 */           nResult = this.outStockBillService.check(outId, response).intValue();
/*      */         }
/*      */       }
/*  683 */       if (nResult > 0) {
/*  684 */         DbConnection.commit();
/*  685 */         String[] heads = { "intgr", "cashCoup" };
/*  686 */         Object[] datas = { saleBillModel.getIntgr(), 
/*  687 */           saleBillModel.getCashCoup() };
/*  688 */         ResponseUtils.toGsonEbRst(heads, datas, response);
/*  689 */         return; }
/*  690 */       DbConnection.rollback();
/*  691 */       PbPaid.getResponse(nResult, response);
/*      */     }
/*      */     catch (Exception e) {
/*  694 */       DbConnection.rollback();
/*  695 */       logger.error(e);
/*  696 */       ResponseUtils.setErrorMsgResponse(
/*  697 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/*  698 */         e.getMessage(), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @Transactional
/*      */   @RequestMapping(value={"edit/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*      */   public void edit(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId)
/*      */   {
/*      */     try
/*      */     {
/*  716 */       int nResult = 0;
/*  717 */       ParserDataSetJson p = new ParserDataSetJson(
/*  718 */         request.getParameter("data"));
/*  719 */       nResult += this.dao.applyUpdates(p);
/*      */ 
/*  721 */       ParserDataSetJson pDetl = ParserDataSetJson.fromString(request
/*  722 */         .getParameter("detl"));
/*  723 */       nResult += this.saleDetailDao.applyUpdates(pDetl);
/*      */ 
/*  725 */       ParserDataSetJson pPay = ParserDataSetJson.fromString(
/*  726 */         RequestUtils.getString(request, "pay"));
/*  727 */       nResult += this.saleBillPayDAO.applyUpdates(pPay);
/*      */ 
/*  729 */       ParserDataSetJson pCheck = 
/*  730 */         ParserDataSetJson.fromString(RequestUtils.getString(request, "chkPay"));
/*  731 */       nResult += this.bussbillpaycheckDao.applyUpdates(pCheck);
/*      */ 
/*  733 */       ParserDataSetJson pPos = ParserDataSetJson.fromString(
/*  734 */         RequestUtils.getString(request, "posPay"));
/*  735 */       nResult += this.bussbillPayPosDao.applyUpdates(pPos);
/*      */ 
/*  737 */       ParserDataSetJson pVCard = 
/*  738 */         ParserDataSetJson.fromString(RequestUtils.getString(request, "vicePay"));
/*  739 */       nResult += this.saleBillPayVCardDao.applyUpdates(pVCard);
/*      */ 
/*  741 */       if (nResult > 0) {
/*  742 */         DbConnection.commit();
/*  743 */         ResponseUtils.setSuccessResponse(response);
/*  744 */         return; }
/*  745 */       DbConnection.rollback();
/*  746 */       ResponseUtils.setSqlResultResponse(nResult, 
/*  747 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/*  748 */         response);
/*      */     }
/*      */     catch (Exception e) {
/*  751 */       DbConnection.rollback();
/*  752 */       logger.error(e);
/*  753 */       ResponseUtils.setErrorMsgResponse(
/*  754 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/*  755 */         e.getMessage(), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @Transactional
/*      */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*      */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*      */   {
/*  771 */     String id = RequestUtils.getStringOfId(request);
/*      */     try {
/*  773 */       String[] strParams = id.split(",");
/*  774 */       int nResult = this.dao.deleteParams(strParams);
/*  775 */       if (nResult > 0) {
/*  776 */         nResult += this.saleDetailDao.deleteOfIds(strParams);
/*  777 */         nResult += this.saleBillPayDAO.deleteOfIds(strParams);
/*  778 */         nResult += this.bussbillpaycheckDao.deleteOfbussIds(strParams);
/*  779 */         nResult += this.bussbillPayPosDao.deleteOfbussIds(strParams);
/*      */       }
/*  781 */       if (nResult > 0)
/*  782 */         DbConnection.commit();
/*      */       else {
/*  784 */         DbConnection.rollback();
/*      */       }
/*  786 */       ResponseUtils.setSqlResultResponse(nResult, 
/*  787 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/*  788 */         response);
/*      */     }
/*      */     catch (Exception e) {
/*  791 */       DbConnection.rollback();
/*  792 */       logger.error(e);
/*  793 */       ResponseUtils.setErrorMsgResponse(
/*  794 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/*  795 */         e.getMessage(), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   private int paidDetailOfbsbill(Long id, Long bussId, Long userId, String userName, SaleBillModel saleBillModel, HttpServletRequest request, HttpServletResponse response)
/*      */     throws SQLException, Exception
/*      */   {
/*  804 */     int nResult = 0;
/*  805 */     String memo = "";
/*  806 */     GsonHeadOneRow r = this.dao.getOneRowOfId(id);
/*  807 */     if (r != null) {
/*  808 */       Long shopId = (Long)r.getValueOfName("shopId");
/*  809 */       Long memberId = (Long)r.getValueOfName("memberId");
/*  810 */       String billNo = (String)r.getValueOfName("BillNo");
/*  811 */       saleBillModel.setBillNo(billNo);
/*      */ 
/*  816 */       String memo1 = (String)r.getValueOfName("Memo");
/*  817 */       if (memo1 != null) {
/*  818 */         memo = memo1;
/*      */       }
/*  820 */       Double dDeposit = Double.valueOf(0.0D);
/*  821 */       Double dIntAmt = Double.valueOf(0.0D);
/*  822 */       Double dCach = Double.valueOf(0.0D);
/*  823 */       Double payCashMny = Double.valueOf(0.0D);
/*  824 */       Double payDisctCoup = Double.valueOf(0.0D);
/*      */ 
/*  826 */       if (ObjectComm.objectToDouble(r.getValueOfName("FactAmt"), Integer.valueOf(0)).doubleValue() == 0.0D) {
/*  827 */         this.memberLogDAO.insertMemberLogBuss(MemberActConst.PAID, billNo, 
/*  828 */           dIntAmt, dDeposit, dCach, dCach, memberId, userId, 
/*  829 */           userName);
/*  830 */         return 1;
/*      */       }
/*  832 */       Integer stId = ObjectComm.objectToInteger(r.getValueOfName("stID"), 
/*  833 */         Integer.valueOf(0));
/*  834 */       Double payDisct = ObjectComm.objectToDouble(
/*  835 */         r.getValueOfName("PayDisctCoup"), Integer.valueOf(0));
/*  836 */       Integer payIntAmt = ObjectComm.objectToInteger(
/*  837 */         r.getValueOfName("PayIntAmt"), Integer.valueOf(0));
/*  838 */       Double payCash = ObjectComm.objectToDouble(
/*  839 */         r.getValueOfName("cashAmt"), Integer.valueOf(0));
/*  840 */       Double payDepstAmt = ObjectComm.objectToDouble(
/*  841 */         r.getValueOfName("depstAmt"), Integer.valueOf(0));
/*  842 */       Double payCheck = ObjectComm.objectToDouble(
/*  843 */         r.getValueOfName("chkAmt"), Integer.valueOf(0));
/*  844 */       Double payCredit = ObjectComm.objectToDouble(
/*  845 */         r.getValueOfName("regAmt"), Integer.valueOf(0));
/*  846 */       Double viceAmt = ObjectComm.objectToDouble(
/*  847 */         r.getValueOfName("viceAmt"), Double.valueOf(0.0D));
/*  848 */       if ((payCredit != null) && (payCredit.doubleValue() > 0.0D)) {
/*  849 */         this.memberLogDAO.insertMemberLogBuss(MemberActConst.PAID, billNo, 
/*  850 */           dIntAmt, dDeposit, dCach, dCach, memberId, userId, 
/*  851 */           userName);
/*  852 */         return 1;
/*      */       }
/*      */ 
/*  855 */       if (viceAmt.doubleValue() > 0.0D) {
/*  856 */         nResult = paidViceCard(id, shopId, request, response);
/*      */       }
/*      */ 
/*  860 */       Double payPos = ObjectComm.objectToDouble(
/*  861 */         r.getValueOfName("bnkAmt"), Integer.valueOf(0));
/*      */ 
/*  863 */       Double payCashCoupAmtMny = ObjectComm.objectToDouble(
/*  864 */         r.getValueOfName("cashCoupAmt"), Integer.valueOf(0));
/*  865 */       if ((payIntAmt != null) && (payIntAmt.intValue() != 0)) {
/*  866 */         dIntAmt = Double.valueOf(dIntAmt.doubleValue() + payIntAmt.intValue());
/*      */       }
/*  868 */       if ((payDepstAmt != null) && (payDepstAmt.doubleValue() != 0.0D)) {
/*  869 */         dDeposit = Double.valueOf(dDeposit.doubleValue() + payDepstAmt.doubleValue());
/*      */       }
/*  871 */       if ((payCash != null) && (payCash.doubleValue() != 0.0D)) {
/*  872 */         dCach = Double.valueOf(dCach.doubleValue() + payCash.doubleValue());
/*      */       }
/*  874 */       if ((payCheck != null) && (payCheck.doubleValue() != 0.0D)) {
/*  875 */         dCach = Double.valueOf(dCach.doubleValue() + payCheck.doubleValue());
/*      */       }
/*  877 */       if ((payCredit != null) && (payCredit.doubleValue() > 0.0D)) {
/*  878 */         dCach = Double.valueOf(dCach.doubleValue() + payCredit.doubleValue());
/*      */       }
/*      */ 
/*  883 */       if ((payPos != null) && (payPos.doubleValue() != 0.0D)) {
/*  884 */         dCach = Double.valueOf(dCach.doubleValue() + payPos.doubleValue());
/*      */       }
/*  886 */       if ((payCashCoupAmtMny != null) && (payCashCoupAmtMny.doubleValue() != 0.0D)) {
/*  887 */         payCashMny = Double.valueOf(payCashMny.doubleValue() + payCashCoupAmtMny.doubleValue());
/*      */       }
/*  889 */       if ((payDisct != null) && (payDisct.doubleValue() != 0.0D))
/*  890 */         payDisctCoup = Double.valueOf(payDisctCoup.doubleValue() + payDisct.doubleValue());
/*      */       GsonHeadManyRows detailIDsRslt;
/*      */       int i;
/*      */   
/*      */       Long detailId;
/*  893 */       if (dIntAmt.doubleValue() > 0.0D) {
/*  894 */         detailIDsRslt = this.integralDetailDAO
/*  895 */           .getSelectMemIntDtialRslt(memberId, shopId);
/*  896 */         if ((detailIDsRslt != null) && (detailIDsRslt.getDataLength() > 0)) {
/*  897 */           Integer memberIntegral = Integer.valueOf(0);
/*  898 */           for (i = 0; i < detailIDsRslt.getDataLength(); ++i) {
/*  899 */             Integer intAmtTemp = (Integer)detailIDsRslt
/*  900 */               .getValueOfName("Integral", i);
/*  901 */             memberIntegral = Integer.valueOf(memberIntegral.intValue() + intAmtTemp.intValue());
/*      */           }
/*  903 */           if (memberIntegral.intValue() >= dIntAmt.doubleValue()) {
/*  904 */             Integer tempIntAmt = Integer.valueOf(dIntAmt.intValue());
/*  905 */             boolean decIntAmt = true;
/*  906 */             for (i = 0; i < detailIDsRslt.getDataLength(); ++i) {
/*  907 */               Integer intAmt = (Integer)detailIDsRslt
/*  908 */                 .getValueOfName("Integral", i);
/*  909 */               detailId = (Long)detailIDsRslt
/*  910 */                 .getValueOfName("DetailID", i);
/*  911 */               Integer intLog = Integer.valueOf(0);
/*  912 */               if (tempIntAmt.intValue() - intAmt.intValue() < 0) {
/*  913 */                 intLog = tempIntAmt;
/*      */               }
/*  915 */               tempIntAmt = Integer.valueOf(tempIntAmt.intValue() - intAmt.intValue());
/*  916 */               if (!(decIntAmt)) break;
/*  917 */               if (tempIntAmt.intValue() >= 0)
/*      */               {
/*  919 */                 nResult = nResult + this.integralDetailDAO
/*  919 */                   .updateIntAmtDtlStatusOfID(
/*  920 */                   memberId, detailId);
/*      */ 
/*  922 */                 nResult = nResult + this.integralConsumeRecordDAO
/*  922 */                   .insertIntgCrIt(detailId, billNo, 
/*  923 */                   intAmt, bussId, memo);
/*  924 */                 if (tempIntAmt.intValue() == 0)
/*  925 */                   decIntAmt = false;
/*      */               }
/*      */               else {
/*  928 */                 intAmt = Integer.valueOf(intAmt.intValue() - intLog.intValue());
/*      */ 
/*  930 */                 nResult = nResult + this.integralDetailDAO
/*  930 */                   .updateIntAmtMemberIt(intAmt, 
/*  931 */                   memberId, detailId);
/*      */ 
/*  933 */                 nResult = nResult + this.integralConsumeRecordDAO
/*  933 */                   .insertIntgCrIt(detailId, billNo, 
/*  934 */                   intLog, bussId, memo);
/*  935 */                 decIntAmt = false;
/*      */               }
/*      */ 
/*      */             }
/*      */ 
/*  941 */             Integer sum = 
/*  942 */               Integer.valueOf(this.integralDetailDAO
/*  942 */               .selectIntAmtTotal(memberId));
/*  943 */             nResult += this.memberDAO.updateMemberIntAmt(sum, memberId);
/*      */ 
/*  945 */             nResult = nResult + this.shopMemberDAO
/*  945 */               .updateMemberIntAmt(sum, 
/*  945 */               memberId, shopId);
/*  946 */             }
/*  947 */           return -1;
/*      */         }
/*      */ 
/*  951 */         return -4;
/*      */       }
/*      */ 
/*  956 */       if (payCashMny.doubleValue() > 0.0D) {
/*  957 */         label1039: detailIDsRslt = this.memberCashCouponDetailDAO
/*  958 */           .getSelectCashCouponDtialRslt(memberId, shopId);
/*  959 */         if ((detailIDsRslt != null) && (detailIDsRslt.getDataLength() > 0)) {
/*  960 */           Double memberCashCpon = Double.valueOf(0.0D);
/*  961 */           for (i = 0; i < detailIDsRslt.getDataLength(); ++i) {
/*  962 */             Double cashCponTemp = 
/*  963 */               ObjectComm.objectToDouble(detailIDsRslt.getValueOfName(
/*  964 */               "FaceValue", i), Integer.valueOf(0));
/*  965 */             memberCashCpon = Double.valueOf(memberCashCpon.doubleValue() + cashCponTemp.doubleValue());
/*      */           }
/*  967 */           if (memberCashCpon.doubleValue() >= payCashMny.doubleValue()) {
/*  968 */             Double tempCashCpon = payCashMny;
/*  969 */             boolean decCashCpon = true;
/*  970 */             for (i = 0; i < detailIDsRslt.getDataLength(); ++i) {
/*  971 */               Double cashCpon = ObjectComm.objectToDouble(
/*  972 */                 detailIDsRslt
/*  973 */                 .getValueOfName("FaceValue", i), Integer.valueOf(0));
/*  974 */               detailId = (Long)detailIDsRslt
/*  975 */                 .getValueOfName("DetailID", i);
/*  976 */               Double cashLog = Double.valueOf(0.0D);
/*  977 */               if (tempCashCpon.doubleValue() - cashCpon.doubleValue() < 0.0D) {
/*  978 */                 cashLog = tempCashCpon;
/*      */               }
/*  980 */               tempCashCpon = Double.valueOf(tempCashCpon.doubleValue() - cashCpon.doubleValue());
/*  981 */               if (!(decCashCpon)) break;
/*  982 */               if (tempCashCpon.doubleValue() >= 0.0D)
/*      */               {
/*  984 */                 nResult = nResult + this.memberCashCouponDetailDAO
/*  984 */                   .updateCashCouponDtlStatusOfID(
/*  985 */                   memberId, detailId);
/*      */ 
/*  987 */                 nResult = nResult + this.memberCashCouponConsumeRecordDAO
/*  987 */                   .insertCashConpConsum(detailId, 
/*  988 */                   billNo, cashCpon, bussId, 
/*  989 */                   memo);
/*  990 */                 if (tempCashCpon.doubleValue() == 0.0D)
/*  991 */                   decCashCpon = false;
/*      */               }
/*      */               else {
/*  994 */                 cashCpon = Double.valueOf(cashCpon.doubleValue() - cashLog.doubleValue());
/*      */ 
/*  996 */                 nResult = nResult + this.memberCashCouponDetailDAO
/*  996 */                   .updateCashCouponMemberCs(cashCpon, 
/*  997 */                   memberId, detailId);
/*      */ 
/*  999 */                 nResult = nResult + this.memberCashCouponConsumeRecordDAO
/*  999 */                   .insertCashConpConsum(detailId, 
/* 1000 */                   billNo, cashLog, bussId, 
/* 1001 */                   memo);
/* 1002 */                 decCashCpon = false;
/*      */               }
/*      */ 
/*      */             }
/*      */ 
/* 1009 */             Double sum = this.memberCashCouponDetailDAO
/* 1010 */               .selectSqlCashCouponDtlSum(memberId);
/* 1011 */             nResult = this.memberDAO.updateMemberCashCoup(sum, memberId);
/* 1012 */             nResult = this.shopMemberDAO.updateMemberCashCoup(sum, 
/* 1013 */               memberId, shopId);
/* 1014 */            }
/* 1015 */           return -3;
/*      */         }
/*      */ 
/* 1018 */         return -6;
/*      */       }
/*      */ 
/* 1022 */       if (dDeposit.doubleValue() > 0.0D)
/*      */       {
/* 1024 */         label1425: nResult = nResult + 
/* 1024 */           PbPaid.getPositDeposit(dDeposit, memberId, billNo, 
/* 1024 */           shopId, bussId, memo);
/* 1025 */         if (nResult < 0)
/* 1026 */           return nResult;
/*      */       }
/*      */       CSessionUser sessionUser;
/* 1031 */       if (dCach.doubleValue() > 0.0D) {
/* 1032 */         nResult += this.memberDAO.updateMemberInc(memberId, dCach);
/*      */ 
/* 1034 */         nResult = nResult + this.shopMemberDAO
/* 1034 */           .updateMemberInc(memberId, dCach, 
/* 1034 */           shopId);
/* 1035 */         sessionUser = 
/* 1036 */           UserSessionInfo.user_getUserOfRequest(request);
/*      */ 
/* 1039 */         nResult = nResult + 
/* 1039 */           PbPaid.getGivePresentSaleBill(sessionUser, dCach, 
/* 1038 */           id, bussId, memberId, shopId, stId, Boolean.valueOf(false), memo, 
/* 1039 */           saleBillModel);
/* 1040 */         if (nResult < 0) {
/* 1041 */           return nResult;
/*      */         }
/*      */ 
/*      */       }
/*      */ 
/* 1047 */       if (dIntAmt.doubleValue() < 0.0D) {
/* 1048 */         int nrst = 0;
/* 1049 */         nrst = 
/* 1050 */           PbPaid.getNtiveIntegral(bussId, dIntAmt.intValue(), memo);
/* 1051 */         if (nrst < 0)
/* 1052 */           return nrst;
/* 1053 */         if ((nrst == 0) || (nrst > 0)) {
/* 1054 */           nResult += nrst;
/*      */         }
/*      */ 
/*      */       }
/*      */ 
/* 1059 */       if (payCashMny.doubleValue() < 0.0D) {
/* 1060 */         nResult += PbPaid.getNtiveCashConp(bussId, payCashMny, memo);
/* 1061 */         if (nResult < 0) {
/* 1062 */           return -7;
/*      */         }
/*      */ 
/*      */       }
/*      */ 
/* 1067 */       if (dDeposit.doubleValue() < 0.0D)
/*      */       {
/* 1069 */         nResult = nResult + 
/* 1069 */           PbPaid.getNtiveDopsit(dDeposit, memberId, billNo, 
/* 1069 */           shopId, userName, bussId, memo);
/* 1070 */         if (nResult < 0) {
/* 1071 */           return nResult;
/*      */         }
/*      */ 
/*      */       }
/*      */ 
/* 1076 */       if (dCach.doubleValue() < 0.0D) {
/* 1077 */         nResult += PbPaid.getNtiveCash(memberId, dCach, shopId);
/* 1078 */         sessionUser = 
/* 1079 */           UserSessionInfo.user_getUserOfRequest(request);
/*      */ 
/* 1081 */         nResult = nResult + 
/* 1081 */           PbPaid.getGivePresent(sessionUser, dCach, bussId, 
/* 1081 */           memberId, stId, Boolean.valueOf(true), memo);
/* 1082 */         if (nResult < 0) {
/* 1083 */           return nResult;
/*      */         }
/*      */       }
/*      */ 
/* 1087 */       GsonHeadOneRow pa = this.shopMemberDAO.getPaidOneRowOfMemberId(memberId, 
/* 1088 */         shopId);
/* 1089 */       if ((pa != null) && (pa.isExistsData())) {
/* 1090 */         Long outId = this.memberDAO.getOutMIdOfId(memberId);
/* 1091 */         if ((outId != null) && (outId.longValue() > 0L)) {
/* 1092 */           pa.autoAddHeadData("shopId", 
/* 1093 */             ShopMap.getOutIdOfShopId(shopId));
/* 1094 */           String sData = "data=" + 
/* 1095 */             pa.objectToJsonStr() + "&" + "id" + 
/* 1096 */             "=" + outId;
/* 1097 */           String sUrl = "ptmember/editPaid";
/* 1098 */           GsonEbRst rst = HttpGsonPtResponseUtils.postPtEbRst(sUrl, 
/* 1099 */             sData, response);
/* 1100 */           if ((rst == null) || (!(rst.isSuccess())))
/* 1101 */             return -14;
/*      */         }
/*      */       }
/*      */       else {
/* 1105 */         return -14;
/*      */       }
/*      */ 
/* 1134 */       this.memberLogDAO
/* 1135 */         .insertMemberLogBuss(MemberActConst.PAID, billNo, dIntAmt, 
/* 1136 */         dDeposit, dCach, dCach, memberId, userId, userName);
/*      */     }
/* 1138 */     return nResult;
/*      */   }
/*      */ 
/*      */   @RequestMapping(value={"find/shopId/{shopId}/vCard/{saleId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*      */   public void getListVCardId(HttpServletRequest request, HttpServletResponse response, @PathVariable("saleId") Long saleId)
/*      */   {
/*      */     try {
/* 1145 */       GsonEbRst gsonEbRst = this.saleBillPayVCardDao.getGsonOfSaleId(saleId);
/* 1146 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*      */     } catch (SQLException e) {
/* 1148 */       logger.error(e);
/* 1149 */       ResponseUtils.setErrorMsgResponse(
/* 1150 */         RequestUtils.getFindDataErrorMessage(request), response);
/*      */     }
/*      */   }
/*      */ }

/* Location:           C:\Users\Administrator\Desktop\鏂板缓鏂囦欢澶筡WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.store.salebill.controller.SaleBillController
 * JD-Core Version:    0.5.3
 */